package com.example.demo.controller;

import com.example.demo.service.impl.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author littlebadfox
 * @date 2022-04-23-21:50
 * @desc
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    UserService userService;

//    login方法
    @RequestMapping("/login")
    public String login(@RequestParam("code") String code){
        String str=userService.loginUserApi(code);
        //获得用户的openid和session 自定义token存入到缓存中，通过缓存检验登录状态，可以稍后完成
        System.out.println(str);
        return str;
    }
}
